using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GamePanelMediator : PureMVC.Patterns.Mediator
{
    public new const string NAME = "GamePanelMediator";
    private GamePanelView View;
    GameObject bagPanel, shopPanel;
    public GamePanelMediator(object viewCompoent) : base(NAME, viewCompoent)
    {

        View = ((GameObject)ViewComponent).GetComponent<GamePanelView>();
        View.Bag.onClick.AddListener(OpenBagPanel);
        View.Shop.onClick.AddListener(OpenShopPanel);
    }

    private void OpenShopPanel()
    {
        //GameObject obj = GameObjectUtility.Instance.CreateGameObject("_Prefabs/GamerPanelView");
        //Facade.RegisterMediator(new GamePanelMediator(obj));
    }

    private void OpenBagPanel()
    {
        if (bagPanel == null)
        {
            bagPanel = GameObjectUtility.Instance.CreateGameObject("_Prefabs/BagPanelView");
            Facade.RegisterMediator(new BagPanelMediator(bagPanel));
        }
        else
        {
            bagPanel.SetActive(true);
        }
    }
}
